package net.mihome.app.bean;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Created by ZHAO on 2015/2/1 0001.
 */
public class Building {
    private Integer id;
    private String name;

    public static Building parse(Map map){
        if(map!=null){
            Building building=new Building();
            Double idDouble= (Double) map.get("id");
            building.setId(idDouble.intValue());
            building.setName((String) map.get("name"));
            return building;
        }else{
            return null;
        }
    }
    public static List<Building> parseList(List<Map> list){
        if(list!=null&&!list.isEmpty()){
            List<Building> buildingList=new ArrayList<>();
            Iterator<Map>  iterator=list.iterator();
            while(iterator.hasNext()){
                Map map=iterator.next();
                Building building=parse(map);
                buildingList.add(building);
            }
            return buildingList;
        }else{
            return null;
        }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
